package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDemo6 {
    public static void main(String[] args) {
        try (Connection con = DBUtil.getConnection();)
        {
            Statement statement=con.createStatement();
            String aql="SELECT t.name,t.gender,c.name,c.floor\n" +
                    "FROM teacher t,class c\n" +
                    "WHERE t.id=c.teacher_id\n" +
                    "AND t.name='王克晶'";
            ResultSet rs=statement.executeQuery(aql);
            while (rs.next()) {
                String name = rs.getString("t.name");
                String gender = rs.getString("t.gender");
                String name1 = rs.getString("c.name");
                String floor = rs.getString("c.floor");
                System.out.println(name + "," + gender + "," + name1 + "," + floor);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
